package com.yanqu.road.server.manger.player;

import com.yanqu.road.entity.config.expression.ExpressionInfo;
import com.yanqu.road.logic.bussiness.config.ExpressionConfigBusiness;
import com.yanqu.road.server.TempMgr;

import java.util.Map;

public class ChatConfigMgr extends TempMgr {

    private static Map<Integer, ExpressionInfo> expressionInfoMap;

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        expressionInfoMap = ExpressionConfigBusiness.getExpressionInfoMap();
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return true;
    }

    /**
     * 通过编号获取表情id
     * @return
     */
    public static ExpressionInfo getExpressionByNum(int num) {
        for (ExpressionInfo expressionInfo : expressionInfoMap.values()) {
            if (expressionInfo.getNum() == num) {
                return expressionInfo;
            }
        }
        return null;
    }
}
